


clear all 
use the_dataset.dta

keep if  standard == 1

global covariates3 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9

* define business cycle
gen     cycle = 1 if ANOENC2 > 2006 & ANOENC2 < 2009
replace cycle = 1 if ANOENC2 > 2013 & ANOENC2 < 2017
replace cycle = 2 if ANOENC2 > 2008 & ANOENC2 < 2014

* Define Participation
gen c_c1 = 1 if culture1 > 0
gen c_c2 = 1 if culture2 > 0
replace c_c2 = 0 if culture2 == 0

* ATET Participation
preserve
keep if case_1==1 & cycle == 1
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

preserve
keep if case_1==1 & cycle == 2
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

preserve
keep if case_2==1 & cycle == 1
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

preserve
keep if case_2==1 & cycle == 2
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* estimate T01 Growing period
preserve
keep if case_1==1  & c_c2 == 1 & cycle == 1
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* estimate T01 recession period
preserve
keep if case_1==1  & c_c2 == 1 & cycle == 2
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* estimate T12 Growing period
preserve
keep if case_2==1  & c_c2 == 1 & cycle == 1
bys unemp: sum culture_d
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* estimate T12 recession period
preserve
keep if case_2==1  & c_c2 == 1 & cycle == 2
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(unemp) xvar($covariates3) sle 
sum unemp if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore


********************* INVERSE TREATMENT ****************************************


clear all 
use the_dataset.dta

keep if  dataset_inverse == 1

global covariates3 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9

* define business cycle
gen     cycle = 1 if ANOENC2 > 2006 & ANOENC2 < 2009
replace cycle = 1 if ANOENC2 > 2013 & ANOENC2 < 2017
replace cycle = 2 if ANOENC2 > 2008 & ANOENC2 < 2014

* Participation
gen c_c1 = 1 if culture1 > 0
gen c_c2 = 1 if culture2 > 0
replace c_c2 = 0 if culture2 == 0

* Gen inverse treatment 
gen case_3 = 1 if unemp_t1==1 & unemp_t2<2 & unemp_t2>=0
gen case_4 = 1 if unemp_t1==2 & unemp_t2<3 & unemp_t2>=1

gen     treated = 1 if unemp==-1
replace treated = 0 if unemp==0


* growth, T10
preserve
keep if case_3==1 & cycle == 1
absdid c_c2, tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* Cop
keep if c_c2==1 
bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3)
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean)) 
absdid income_d  , tvar(treated) xvar($covariates3)
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean)) 
restore

* Recession, T10
preserve
keep if case_3==1 & cycle == 2
absdid c_c2, tvar(treated) xvar($covariates3) 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* Cop
keep if c_c2==1 
bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* growth, T21
preserve
keep if case_4==1 & cycle == 1
* drop an outlier
drop if income_d < -7400 & treated == 0
absdid c_c2, tvar(treated) xvar($covariates3) 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* Cop
keep if c_c2==1 
bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* recession, T21
preserve
* drop an outlier
drop if income_d < -7400 & treated == 0
keep if case_4==1 & cycle == 2
absdid c_c2, tvar(treated) xvar($covariates3) 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* Cop
keep if c_c2==1 
bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle 
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore


























